
#include <signal.h>

#include <iostream>

#include <workflow/WFFacilities.h>
using std::cout;
using std::endl;
using std::string;

static WFFacilities::WaitGroup waitGroup(1);

void sighandler(int num)
{
    printf(">> sig num %d is comming\n", num);
    //调用一次done方法，计数器的值减1
    waitGroup.done();
}

void httpCallback(WFHttpTask * )
{
    printf("httpCallback is running\n");
}

void test0()
{
    signal(SIGINT, sighandler);
    //1. 创建HttpTask
    string url = "www.baidu.com";
    auto httpTask = WFTaskFactory::create_http_task(url, 1, 1, httpCallback);
    //2. 设置任务的属性
    
    //3. 启动HttpTask任务，交给框架调度执行
    httpTask->start();

    //当调用wait方法会阻塞当前线程
    waitGroup.wait();
    cout << "test0 exit" << endl;
}


int main()
{
    test0();
    return 0;
}

